package com.ruoyi.projects.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.SlMemberCardRecord;
import com.ruoyi.projects.service.ISlMemberCardRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员卡使用记录Controller
 * 
 * @author yangz
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/projects/SlMemberCardRecord")
public class SlMemberCardRecordController extends BaseController
{
    @Autowired
    private ISlMemberCardRecordService slMemberCardRecordService;

    /**
     * 查询会员卡使用记录列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlMemberCardRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlMemberCardRecord slMemberCardRecord)
    {
        startPage();
        List<SlMemberCardRecord> list = slMemberCardRecordService.selectSlMemberCardRecordList(slMemberCardRecord);
        return getDataTable(list);
    }

    /**
     * 导出会员卡使用记录列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlMemberCardRecord:export')")
    @Log(title = "会员卡使用记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlMemberCardRecord slMemberCardRecord)
    {
        List<SlMemberCardRecord> list = slMemberCardRecordService.selectSlMemberCardRecordList(slMemberCardRecord);
        ExcelUtil<SlMemberCardRecord> util = new ExcelUtil<SlMemberCardRecord>(SlMemberCardRecord.class);
        util.exportExcel(response, list, "会员卡使用记录数据");
    }

    /**
     * 获取会员卡使用记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:SlMemberCardRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(slMemberCardRecordService.selectSlMemberCardRecordById(id));
    }

    /**
     * 新增会员卡使用记录
     */
    @PreAuthorize("@ss.hasPermi('projects:SlMemberCardRecord:add')")
    @Log(title = "会员卡使用记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlMemberCardRecord slMemberCardRecord)
    {
        return toAjax(slMemberCardRecordService.insertSlMemberCardRecord(slMemberCardRecord));
    }

    /**
     * 修改会员卡使用记录
     */
    @PreAuthorize("@ss.hasPermi('projects:SlMemberCardRecord:edit')")
    @Log(title = "会员卡使用记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlMemberCardRecord slMemberCardRecord)
    {
        return toAjax(slMemberCardRecordService.updateSlMemberCardRecord(slMemberCardRecord));
    }

    /**
     * 删除会员卡使用记录
     */
    @PreAuthorize("@ss.hasPermi('projects:SlMemberCardRecord:remove')")
    @Log(title = "会员卡使用记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slMemberCardRecordService.deleteSlMemberCardRecordByIds(ids));
    }
}
